package com.edu.whty.entity.capacity;

import com.edu.whty.entity.base.BaseEntity;

import java.text.DecimalFormat;
import java.util.List;
import java.util.Objects;

/**
 * @desc	网盘容量表实体类
 * @author	
 * @date	2014-8-6
 */
public class Capacity extends BaseEntity {

    /**
	 * 
	 */
	private static final long serialVersionUID = 8574804817086454162L;

	/** 主键 */
    private String capacityId;

    /** 属主ID */
    private String ownerId;

	/**
	 * 用户列表，用作批量查询
	 */
	private List<String> ownerIdList;

    /** 总容量 */
    private Long maxCapacity;

    /** 已用容量 */
    private Long usedCapacity;

    /** 使用率 */
    private Float usedRate;

	private String usedCapacitySize;
    
    private String maxCapacitySize;
    
    private String realName;
	
	private Integer diskType;//用户网盘类型,0-用户，1-机构
	
	private String ownerName;  //属主Name 用户登陆账号
	
	private String platformCode;  //属主platformCode

	private String orgId;  //学校id

	private String orgName;  //学校name

	public String getOrgId() {
		return orgId;
	}

	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}


    public String getUsedCapacitySize() {
    	if(!Objects.isNull(usedCapacity)){
    		if(usedCapacity > maxCapacity){
    			usedCapacity = maxCapacity;
    		}
	    	DecimalFormat   df   =new   DecimalFormat("#0.00");
	    	float size = usedCapacity / (float)1024;
	    	if(size < 1024){
	    	  return df.format(size)+"KB";
	    	}else if(size >= 1024 && size < 1024*1024){
	    	  return df.format(size/1024)+"MB";
	    	}else if(size >= 1024*1024){
	    	  return df.format(size/(1024*1024))+"GB";
	    	}
    	}
    	return null;
	}

	public void setUsedCapacitySize(String usedCapacitySize) {
		this.usedCapacitySize = usedCapacitySize;
	}
	
	public String getMaxCapacitySize() {
		if(!Objects.isNull(usedCapacity)){
	    	DecimalFormat   df   =new   DecimalFormat("#0.00");
	    	float size = maxCapacity / (float)1024;
	    	if(size < 1024){
	    	  return df.format(size)+"KB";
	    	}else if(size >= 1024 && size < 1024*1024){
	    	  return df.format(size/1024)+"MB";
	    	}else if(size >= 1024*1024){
	    	  return df.format(size/(1024*1024))+"GB";
	    	}
    	}
		return null;
	}

	public void setMaxCapacitySize(String maxCapacitySize) {
		this.maxCapacitySize = maxCapacitySize;
	}

	public String getCapacityId() {
        return capacityId;
    }

    public void setCapacityId(String capacityId) {
        this.capacityId = capacityId;
    }

    public String getOwnerId() {
        return ownerId;
    }

    public void setOwnerId(String ownerId) {
        this.ownerId = ownerId;
    }

    public Long getMaxCapacity() {
        return maxCapacity;
    }

    public void setMaxCapacity(Long maxCapacity) {
        this.maxCapacity = maxCapacity;
    }

    public Long getUsedCapacity() {
        return usedCapacity;
    }

    public void setUsedCapacity(Long usedCapacity) {
        this.usedCapacity = usedCapacity;
    }

    public Float getUsedRate() {
        return usedRate;
    }

    public void setUsedRate(Float usedRate) {
        this.usedRate = usedRate;
    }

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public Integer getDiskType() {
		return diskType;
	}

	public void setDiskType(Integer diskType) {
		this.diskType = diskType;
	}

	public String getOwnerName() {
		return ownerName;
	}

	public void setOwnerName(String ownerName) {
		this.ownerName = ownerName;
	}

	public String getPlatformCode() {
		return platformCode;
	}

	public void setPlatformCode(String platformCode) {
		this.platformCode = platformCode;
	}

	public List<String> getOwnerIdList() {
		return ownerIdList;
	}

	public void setOwnerIdList(List<String> ownerIdList) {
		this.ownerIdList = ownerIdList;
	}
}
